<?php

class MY_Controller extends CI_Controller {
	
	var $school_data;
	function __construct()
    {
		$other_uri = array('register', 'popups');
		parent::__construct();
		$this->load->model('M_school');
		$this->school_data = $this->M_school->get_school();
		$uri = $this->uri->segment(1);
		
        if ($this->session->userdata('logged_in'))
        { 
           
		   
		   if($this->uri->segment(1) == 'admin' && $this->session->userdata('usertype') != 'admin')
		   		redirect('home/login/administrator');
					
			if($this->uri->segment(1) == 'student' && $this->session->userdata('usertype') != 'student')
				redirect('home/login/student');
        }
		else {
			if(!in_array($uri, $other_uri))
				redirect('home/login/'.$this->uri->segment(1));	
		}
    }
	

}
?>